<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  <title>Document</title>
  <style>

  </style>
</head>

<body>
  <button>点击按钮，添加</button>

  <script src="./axios.js"></script>
</body>
<script>
  axios.defaults.baseURL = 'http://www.itcbc.com:3006'
  // axios({ method: '', url: '', params: {}, data: {} }).then()

  axios.get('/api/getbooks', {
    params: {
      appkey: 'zhizhi0208'
    }
  })
    .then(({ data: res }) => {
      console.log(res)
    })

  // 演示POST请求
  document.querySelector('button').addEventListener('click', function () {
    // 使用简化方法 axios.post()
    axios.post('/api/addbook', {
      bookname: 'ddd',
      author: 'ddd',
      publisher: 'eee',
      appkey: 'zhizhi0208'
    }).then(({ data }) => {
      console.log(data)
    })
  })
</script>

</html>